<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<%--
The taglib directive below imports the JSTL library. If you uncomment it,
you must also add the JSTL library to the project. The Add Library... action
on Libraries node in Projects view can be used to add the JSTL 1.1 library.
--%>
<%--
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> 
--%>
<%
if(session.getAttribute("un")==null){
    response.sendRedirect("indexAdmin.jsp?page=Admin&url=Login");
    out.println("You must be login..!");
}else{%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<script language="javascript" type="text/javascript" src="../script/validate.js"></script>
<script language="javascript">
   function kiemtra(){
	var fullname = document.form1.txtfullname;
        var address = document.form1.txtaddress;
        var phone = document.form1.txtphone;
        var email = document.form1.txtemail;
        var question = document.form1.txtquestion;
        var compass = document.form1.txtcomfpassword;
        
        
        if( laChuoiRong(fullname.value))
	{
            alert('Full name must be not blank!');
            fullname.focus();
            return false;
	}
        if( laChuoiRong(address.value))
	{
            alert('Address  must be not blank!');
            address.focus();
            return false;
	}
        if( laChuoiRong(phone.value))
	{
            alert('Phone  must be not blank!');
            phone.focus();
            return false;
	}
        if(!laSoNguyen(phone.value) )
	{
            alert('Phone number invalid!');
            phone.focus();
            return false;
	}
        if( laChuoiRong(email.value))
	{
            alert('Email  must be not blank!');
            email.focus();
            return false;
	}
        if( !laEmail(email.value) )
	{
            alert('Email invalid!, Ex: jhon@gmail.com');
            email.focus();
            return false;
	}
        if( laChuoiRong(question.value))
	{
            alert('Question  must be not blank!');
            question.focus();
            return false;
	}
    }
</script>
<%
            String g="";
            String id="";
            String s="";
            String fn="";
            String ad="";
            String pho="";
            String mail="";
            String q="";
            if(session.getAttribute("eid")!=null){
                id=session.getAttribute("eid").toString();
                fn=session.getAttribute("efullname").toString();
                ad=session.getAttribute("eAddress").toString();
                pho=session.getAttribute("ephone").toString();
                mail=session.getAttribute("eemail").toString();
                g=session.getAttribute("egender").toString();
                s=session.getAttribute("estatus").toString();
                q=session.getAttribute("equestion").toString();
            }
            %>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
        <form action="../controllUser" method="Post" name="form1" id="form1" onsubmit="return kiemtra()">
            <h3 align="center">Update User</h3>
            <table>
                <tr>
                    <td>User Name:</td>
                    <td><label><%=id%></label></td>
                    
                    <input type="hidden" name="tmp" value="<%=id%>" />
                    
                </tr>
                <tr>
                    <td>Full Name:</td>
                    <td><input type="text" name="txtfullname" value="<%=fn%>" /></td>
                </tr>
                <tr>
                    <td>Address:</td>
                    <td><textarea name="txtaddress" rows="4" cols="20"><%=ad%>
                    </textarea></td>
                </tr>
                <tr>
                    <td>Phone:</td>
                    <td><input type="text" name="txtphone" value="<%=pho%>" /></td>
                </tr>
                <tr>
                    <td>Email:</td>
                    <td><input type="text" name="txtemail" value="<%=mail%>" /></td>
                </tr>
                <tr>
                    <td>Gender:</td>
                    <td><% if(g==""){%> 
                        
                        Male<input type="radio" name="rdgender" value="Male" checked="true" />
                        Female<input type="radio" name="rdgender" value="Female"/>
                        <%}%>
                        
                        <% if(g.equals("Male")){%>  
                        Male<input type="radio" name="rdgender" value="Male" checked="true" />
                        Female<input type="radio" name="rdgender" value="Female"  />
                        <%}%>
                        
                        <% if(g.equals("Female")){%>
                        Male<input type="radio" name="rdgender" value="Male"  />
                        Female<input type="radio" name="rdgender" value="Female" checked="true" />
                        <%}%>
                    </td>
                </tr>
                <tr>
                    <td>Status:</td>
                    <td>
                        <%
                        if(s==""){%>
                        <select name="dropstatus">
                            <option>Academic</option>
                            <option>Admin</option>
                        </select><%}%>
                        <%
                        if(s.equals("Admin")){%>
                        <select name="dropstatus">
                            <option>Admin</option>
                            <option>Academic</option>
                        </select>
                        <%}%>
                        
                        <%if(s.equals("Academic")){%>
                        <select name="dropstatus">
                            <option>Academic</option>
                            <option>Admin</option>
                        </select>
                        <%}%>
                    </td>
                </tr>
                <tr>
                    <td>Question:</td>
                    <td><input type="text" name="txtquestion" value="<%=q%>" /></td>
                </tr>
                <tr>
                    <td></td>
                    <td>
                        <input type="submit" name="bt" value="Update" />
                        <input type="button" name="btreset" value="Reset" onclick="clear_fields()" />
                    </td>
                </tr>
            </table>
        </form>
    </body>
</html>
<%}%>